pac1811 2.2.0
Loading...
Searching...
No Matches
PAC1811 Click Driver

API for configuring and manipulating PAC1811 Click driver. More...

Topics

 PAC1811 Registers List
 List of registers of PAC1811 Click driver.
 PAC1811 Registers Settings
 Settings for registers of PAC1811 Click driver.
 PAC1811 MikroBUS Map
 MikroBUS pin mapping of PAC1811 Click driver.

Functions

void pac1811_cfg_setup (pac1811_cfg_t *cfg)
 PAC1811 configuration object setup function.
err_t pac1811_init (pac1811_t *ctx, pac1811_cfg_t *cfg)
 PAC1811 initialization function.
err_t pac1811_default_cfg (pac1811_t *ctx)
 PAC1811 default configuration function.
err_t pac1811_send_byte (pac1811_t *ctx, uint8_t data_in)
 PAC1811 send single byte function.
err_t pac1811_receive_byte (pac1811_t *ctx, uint8_t *data_out)
 PAC1811 receive single byte function.
err_t pac1811_write_byte (pac1811_t *ctx, uint8_t reg, uint8_t data_in)
 PAC1811 write register function.
err_t pac1811_read_byte (pac1811_t *ctx, uint8_t reg, uint8_t *data_out)
 PAC1811 read register function.
err_t pac1811_block_write (pac1811_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
 PAC1811 write registers function.
err_t pac1811_block_read (pac1811_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
 PAC1811 read registers function.
err_t pac1811_check_communication (pac1811_t *ctx)
 PAC1811 communication check function.
void pac1811_enable_device (pac1811_t *ctx)
 PAC1811 enable device function.
void pac1811_disable_device (pac1811_t *ctx)
 PAC1811 disable device function.
uint8_t pac1811_get_a1_pin (pac1811_t *ctx)
 PAC1811 get A1 pin function.
err_t pac1811_refresh (pac1811_t *ctx)
 PAC1811 refresh function.
err_t pac1811_refresh_global (pac1811_t *ctx)
 PAC1811 global refresh function.
err_t pac1811_refresh_wo_acc_reset (pac1811_t *ctx)
 PAC1811 refresh without accumulator reset function.
err_t pac1811_set_fsr (pac1811_t *ctx, uint8_t vsense_fsr, uint8_t vbus_fsr)
 PAC1811 set full-scale ranges function.
err_t pac1811_read_data (pac1811_t *ctx, pac1811_data_t *data_out)
 PAC1811 read measurement data function.

Detailed Description

API for configuring and manipulating PAC1811 Click driver.

Any initialization code needed for MCU to function properly. Do not remove this line or clock might not be set correctly.

Function Documentation

◆ pac1811_block_read()

err_t pac1811_block_read ( pac1811_t * ctx,
uint8_t reg,
uint8_t * data_out,
uint8_t len )

PAC1811 read registers function.

This function reads a desired number of data bytes starting from the selected register address.

Parameters
[in]ctx: Click context object. See pac1811_t object definition for detailed explanation.
[in]reg: Start register address.
[out]data_out: Output read data buffer.
[in]len: Number of bytes to read.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ pac1811_block_write()

err_t pac1811_block_write ( pac1811_t * ctx,
uint8_t reg,
uint8_t * data_in,
uint8_t len )

PAC1811 write registers function.

This function writes a desired number of data bytes starting from the selected register address.

Parameters
[in]ctx: Click context object. See pac1811_t object definition for detailed explanation.
[in]reg: Start register address.
[in]data_in: Data buffer to be written.
[in]len: Number of bytes to write.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ pac1811_cfg_setup()

void pac1811_cfg_setup ( pac1811_cfg_t * cfg)

PAC1811 configuration object setup function.

This function initializes Click configuration structure to initial values.

Parameters
[out]cfg: Click configuration structure. See pac1811_cfg_t object definition for detailed explanation.
Returns
Nothing.
Note
The all used pins will be set to unconnected state.

◆ pac1811_check_communication()

err_t pac1811_check_communication ( pac1811_t * ctx)

PAC1811 communication check function.

This function verifies communication by reading product and manufacturer IDs and comparing them against expected values.

Parameters
[in]ctx: Click context object. See pac1811_t object definition for detailed explanation.
Returns
  • 0 - Success (IDs match),
  • -1 - Error (IDs mismatch or bus error). See #err_t definition for detailed explanation.
Note
None.

◆ pac1811_default_cfg()

err_t pac1811_default_cfg ( pac1811_t * ctx)

PAC1811 default configuration function.

This function executes a default configuration of PAC1811 Click board.

Parameters
[in]ctx: Click context object. See pac1811_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
This function can consist any necessary configuration or setting to put device into operating mode.

◆ pac1811_disable_device()

void pac1811_disable_device ( pac1811_t * ctx)

PAC1811 disable device function.

This function disables device by setting the PWR pin to low logic state.

Parameters
[in]ctx: Click context object. See pac1811_t object definition for detailed explanation.
Returns
Non.
Note
None.

◆ pac1811_enable_device()

void pac1811_enable_device ( pac1811_t * ctx)

PAC1811 enable device function.

This function enables device by setting the PWR pin to high logic state.

Parameters
[in]ctx: Click context object. See pac1811_t object definition for detailed explanation.
Returns
Non.
Note
None.

◆ pac1811_get_a1_pin()

uint8_t pac1811_get_a1_pin ( pac1811_t * ctx)

PAC1811 get A1 pin function.

This function reads the logic level of the A1 pin.

Parameters
[in]ctx: Click context object. See pac1811_t object definition for detailed explanation.
Returns
Pin state:
  • 0 - Logic low,
  • 1 - Logic high.
Note
None.

◆ pac1811_init()

err_t pac1811_init ( pac1811_t * ctx,
pac1811_cfg_t * cfg )

PAC1811 initialization function.

This function initializes all necessary pins and peripherals used for this Click board.

Parameters
[out]ctx: Click context object. See pac1811_t object definition for detailed explanation.
[in]cfg: Click configuration structure. See pac1811_cfg_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ pac1811_read_byte()

err_t pac1811_read_byte ( pac1811_t * ctx,
uint8_t reg,
uint8_t * data_out )

PAC1811 read register function.

This function reads a single byte from the selected register address.

Parameters
[in]ctx: Click context object. See pac1811_t object definition for detailed explanation.
[in]reg: Register address.
[out]data_out: Output read data byte.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ pac1811_read_data()

err_t pac1811_read_data ( pac1811_t * ctx,
pac1811_data_t * data_out )

PAC1811 read measurement data function.

This function reads accumulated count, voltage, current, and power data, and converts raw codes into SI units, storing the results to the output structure.

Parameters
[in]ctx: Click context object. See pac1811_t object definition for detailed explanation.
[out]data_out: Output measurement data structure. See pac1811_data_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
Conversion depends on configured FSRs.

◆ pac1811_receive_byte()

err_t pac1811_receive_byte ( pac1811_t * ctx,
uint8_t * data_out )

PAC1811 receive single byte function.

This function receives a single byte from the I2C bus.

Parameters
[in]ctx: Click context object. See pac1811_t object definition for detailed explanation.
[out]data_out: Output read data byte.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ pac1811_refresh()

err_t pac1811_refresh ( pac1811_t * ctx)

PAC1811 refresh function.

This function issues a REFRESH command to update measurement registers.

Parameters
[in]ctx: Click context object. See pac1811_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ pac1811_refresh_global()

err_t pac1811_refresh_global ( pac1811_t * ctx)

PAC1811 global refresh function.

This function sends a global REFRESH command via the general-call address and then restores the device's slave address.

Parameters
[in]ctx: Click context object. See pac1811_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
Temporarily switches to general-call address and restores it afterwards.

◆ pac1811_refresh_wo_acc_reset()

err_t pac1811_refresh_wo_acc_reset ( pac1811_t * ctx)

PAC1811 refresh without accumulator reset function.

This function issues a REFRESH_V command to update measurement registers without resetting accumulators.

Parameters
[in]ctx: Click context object. See pac1811_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ pac1811_send_byte()

err_t pac1811_send_byte ( pac1811_t * ctx,
uint8_t data_in )

PAC1811 send single byte function.

This function transmits a single byte on the I2C bus.

Parameters
[in]ctx: Click context object. See pac1811_t object definition for detailed explanation.
[in]data_in: Data byte to send.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ pac1811_set_fsr()

err_t pac1811_set_fsr ( pac1811_t * ctx,
uint8_t vsense_fsr,
uint8_t vbus_fsr )

PAC1811 set full-scale ranges function.

This function configures full-scale ranges (FSR) for V(SENSE) and V(BUS).

Parameters
[in]ctx: Click context object. See pac1811_t object definition for detailed explanation.
[in]vsense_fsr: V(SENSE) FSR selection (see PAC1811_FSR_*).
[in]vbus_fsr: V(BUS) FSR selection (see PAC1811_FSR_*).
Returns
  • 0 - Success,
  • -1 - Error (invalid range or bus error). See #err_t definition for detailed explanation.
Note
None.

◆ pac1811_write_byte()

err_t pac1811_write_byte ( pac1811_t * ctx,
uint8_t reg,
uint8_t data_in )

PAC1811 write register function.

This function writes a single byte to the selected register address.

Parameters
[in]ctx: Click context object. See pac1811_t object definition for detailed explanation.
[in]reg: Register address.
[in]data_in: Data byte to be written.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.